﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SF.Web.UI.pageCs
{
    public class index
    {
        /// <summary>
        /// 加载菜单Html
        /// 此处读取的是商品分类
        /// </summary>
        /// <returns></returns>
        public string LoadMenuHtml()
        {
            //            menuHtml = @"<li data-class='fruits' onclick='home.changeProductClass(&#39;fruits&#39;);' style='width: 71px;'><a id='menu-fruits' href='javascript:void(0);' title='水果' class='current'><span>进口水果</span></a></li>
            //                         <li data-class='milk' onclick='home.changeProductClass(&#39;milk&#39;);' style='width: 71px;'><a id='menu-milk' href='javascript:void(0);' title='水果'><span>特价水果</span></a></li>
            //                         <li data-class='ingredient' onclick='home.changeProductClass(&#39;ingredient&#39;);' style='width: 71px;'><a id='menu-ingredient' href='javascript:void(0);' title='水果'><span>食材食品</span></a></li>
            //                         <li style='width: 71px;'><a id='menu-special' href='http://m2.bingofresh.com/v3.7/home.php#/product_special' title='省钱' onclick='common.buttonClikcStatistics(&#39;index&#39;,&#39;index_special&#39;,&#39;省钱分类&#39;);'><span>省钱</span></a></li>";

            string result = string.Empty;
            BLL.bs_good_type goodTypeBll = new BLL.bs_good_type();
            //一级、无隐藏的分类
            string strWhere = "fatherID=0 and isShow=1";
            var goodTypeList = goodTypeBll.GetModelList(strWhere);
            if (goodTypeList != null && goodTypeList.Any())
            {
                StringBuilder sbHtml = new StringBuilder();
                //排序
                foreach (var goodType in goodTypeList.OrderBy(m => m.sort))
                {
                    //string strLiMenu = string.Format("<li data-class='{0}' onclick='home.changeProductClass(&#39;{1}&#39;);' style='width: 71px;'><a id='menu-{2}' href='javascript:void(0);' title='{3}' class='current'><span>{4}</span></a></li>",
                    //    goodType.id, goodType.id, goodType.id, goodType.typeName, goodType.typeName);

                    string strLi = string.Format("<li data-class='{0}' style='width: 71px;'><a id='menu-{1}' title='{2}' class='current' href='http://www.baidu.com'><span>{3}</span></a></li>",
                        goodType.id, goodType.id, goodType.typeName, goodType.typeName);
                    sbHtml.Append(strLi);
                }
                result = sbHtml.ToString();
            }
            return result;
        }
    }
}
